package com.hxgz.steel.service.Impl;

import com.hxgz.steel.common.ServerResponse;
import com.hxgz.steel.dao.OrderMapper;
import com.hxgz.steel.dto.GetNumbersDto;
import com.hxgz.steel.service.MerchantPandectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author liuhuan
 * @description  店铺总览
 * @date 2019/1/24
 */
@Service
public class MerchantPandectServiceImpl implements MerchantPandectService {

    @Autowired
    private OrderMapper orderMapper;
    /**
     * 获取数据
     * @param userId
     * @return
     */
    @Override
    public ServerResponse getNumbers(Long userId) {
        GetNumbersDto getNumbersDto = new GetNumbersDto();
        //今天成交的数量
        Integer dayCount = orderMapper.getTodayCount(userId);
        getNumbersDto.setDayCount(dayCount);
        //今日成交额
        BigDecimal dayVolume = orderMapper.getDayVolume(userId);
        getNumbersDto.setDayVolume(dayVolume);
        //总成交量
        Integer totleCount = orderMapper.getTotleCount(userId);
        getNumbersDto.setTotleCount(totleCount);
        //总成交额
        BigDecimal totleVolume = orderMapper.getTotleVolume(userId);
        getNumbersDto.setTotleVolume(totleVolume);
        //本年度的每月的订单数
        List<BigDecimal> list = orderMapper.getCountByMonth(userId);
        getNumbersDto.setList(list);
        //今日求购量
        Integer dayAskCount=orderMapper.getDayAskCountByUserId(userId);
        getNumbersDto.setDayAskCount(dayAskCount);
        //历史求购量
        Integer totleAskCount=orderMapper.getTotleAskCountByUserId(userId);
        getNumbersDto.setTotleAskCount(totleAskCount);
        return ServerResponse.createBySuccess(getNumbersDto);
    }
}
